package com.itboye.sunsun.adapter;

import java.util.List;

import com.itboye.sunsun.R;
import com.itboye.sunsun.adapter.WoDeZhuTiAdapter.ViewHolder;
import com.itboye.sunsun.application.App;
import com.itboye.sunsun.beans.WoDePingLunBean.CommentItemBean;
import com.itboye.sunsun.beans.WoDeZhuTiBean.ZhuTiItemBean;
import com.itboye.sunsun.constants.NetPublicConstant;
import com.itboye.sunsun.utils.XImageLoader;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class WoDePingLunAdapter extends BaseAdapter {

	List<CommentItemBean> dataList;
	public WoDePingLunAdapter(List<CommentItemBean> dataList) {
		// TODO Auto-generated constructor stub
		this.dataList=dataList;
	}

	@Override
	public int getCount() {
		
		return dataList.size();
	}

	@Override
	public Object getItem(int position) {
		
		return null;
	}

	@Override
	public long getItemId(int position) {
		
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView==null) {
			convertView=LayoutInflater.from(App.ctx).inflate(R.layout.item_wode_pinglun	, null);
			holder=new ViewHolder();
			holder.head=(ImageView) convertView.findViewById(R.id.head);
			 
			holder.name=(TextView) convertView.findViewById(R.id.name);
			holder.time=(TextView) convertView.findViewById(R.id.time);
			holder.content=(TextView) convertView.findViewById(R.id.content);
			 
			holder.wohuifudepinglun=(TextView) convertView.findViewById(R.id.wohuifudepinglun);
			convertView.setTag(holder);
		}else{
			holder= (ViewHolder) convertView.getTag();
		}
		CommentItemBean bean=dataList.get(position);
		if (bean.getUserInfo()!=null) {
			XImageLoader.load(NetPublicConstant.IMAGE_URL+bean.getUserInfo().getHead(), holder.head);
			holder.name.setText(bean.getUserInfo().getNickname());
		}else{
			 holder.head.setImageBitmap(null);;
			holder.name.setText(bean.getCommentAuthor());
		}
		 
		holder.time.setText(bean.getCommentDatelineShow());
		holder.content.setText(bean.getPostMessage());
		 
		holder.wohuifudepinglun.setText(bean.getCommentComment());
		 
		 
		
		return convertView;
	}
	
	class ViewHolder{
		ImageView head;
		 
		TextView name;
		TextView time;
		TextView content;
		 
		TextView wohuifudepinglun;
	 
	}

}
